<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <button id="close"> 关闭定时器</button>

    <script>

        // 间隔定时器

        // setInterval(function(){
        //     document.write(new Date()+"<br>")

        // },1000)

        //  定时器

        // setTimeout(function(){
        //     document.write("开始执行")
        // },1000)

        // 页码是第几个定时器
        var timer1 = setInterval(function () { console.log("111111111"); }, 1000)
        var timer2 = setTimeout(function () { console.log("22222222222"); }, 3000)

        document.write(timer1 + "--")
        document.write(timer2 + "--")


        // // 关闭定时器
        // clearInterval(timer1)
        // clearTimeout(timer2)
        close.onclick() = function () {
            // clearInterval(timer1)
            window.alert('hello world')
        }
        




    </script>

</body>

</html>